package online.inote.common.shiro;

import java.io.Serializable;

import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.eis.SessionIdGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import online.inote.common.utils.GeneratorIDUtils;

/**
 * <p>
 * Desc:
 * </p>
 *
 * @author XQF SUI
 * @created 2018年8月25日 下午8:34:08
 * @version 1.0
 */
public class ShiroSessionIdGenerator implements SessionIdGenerator {
	
	private Logger logger = LoggerFactory.getLogger(getClass());
	
	private String name;

	public ShiroSessionIdGenerator(String name) {
		this.name = name;
	}

	@Override
	public Serializable generateId(Session session) {
		logger.info("generator生成的sessionhost：[ {} ]", session.getHost());
		return name + "_" + GeneratorIDUtils.GeneratorUUID() + "_" +  session.getHost();
	}
}